package nc.impl.slyy.pub;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.RuntimeEnv;
import nc.itf.slyy.pub.ISlyyWriteXMLItf;
import nc.vo.pub.BusinessException;
import nc.vo.slyy.s00001.QueryCardVO;
import nc.vo.slyy.s00002.AssetcheckVO;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

public class SlyyWrXMLImpl implements ISlyyWriteXMLItf {
	private BaseDAO baseDAO = null;
	protected BaseDAO getBaseDAO() {
		if(baseDAO==null)
			baseDAO = new BaseDAO();
		return baseDAO;
	}
//	public void writeXML(String path,String date) throws BusinessException, IOException {
//		List ls = (List) getBaseDAO().retrieveAll(QueryCardVO.class);  
//		QueryCardVO[] vos = (QueryCardVO[]) ls .toArray(new QueryCardVO[ls.size()]);   
//		Element root = new Element("root");
//		Document doc = new Document(root);
//		Element	data = null;
//		Element	detail = null; 
//		String[] keys = new String[]{"pk_corp","asset_code","asset_name","card_code"};
//		ArrayList al = new ArrayList();
//		for(String s : keys){
//			al.add(s);
//		}
//		for (QueryCardVO vo : vos) { 
//			data =  new Element("data");
//			root.addContent(data);
//			String[] names = vo.getAttributeNames();
//			for (String n : names) {
//				if(al.contains(n)){
//				detail = new Element(n);
//				data.addContent(detail);
//				detail.addContent(vo.getAttributeValue(n) == null ? "" : vo.getAttributeValue(n).toString());
//				}
//			}  
//			 
//		}    
//	     Format format = Format.getPrettyFormat();
//	        format.setEncoding("gb2312");
//
//	    String nchome = RuntimeEnv.getInstance().getNCHome();
//		String filepath = nchome +"\\webapps\\nc_web\\ncupload\\cardinfo\\asset.xml"; 
//		XMLOutputter XMLOut = new XMLOutputter(); 
//		XMLOut.setFormat(format);
//		FileWriter writer = new FileWriter(filepath);
//		XMLOut.output(doc,writer); 
//		 writer.close(); 
//		 
//		
//
//
//	}
	public void updateAssectCheck(ArrayList al) throws BusinessException {
		getBaseDAO().executeUpdate("delete from slyy_assetcheck");
		getBaseDAO().insertVOList(al);
		
	}

}
